/*
remote_cmd.h
offer remote control date type define and function extern
designed by lunanting

---------------------
2021-06-08 15:39:44
create file
---------------------
*/
#ifndef __REMOTE_CMD_H
#define __REMOTE_CMD_H

#include "cli_cmd.h"


/********************string define******************/
#define REMOTE_unemergency      "unemergency"
#define REMOTE_auto_back        "auto_back"
#define REMOTE_recover          "recover"
#define REMOTE_max_hight        "max_hight"
#define REMOTE_forward          "forward"
#define REMOTE_back             "back"
#define REMOTE_left             "left"
#define REMOTE_right            "right"
#define REMOTE_stop             "stop"
#define REMOTE_lidar_blow       "lidar_blow"
#define REMOTE_standby_point    "standby_point"
#define REMOTE_goto_point       "goto_point"

#define REMOTE_max_number       "max_number"
#define REMOTE_park_check       "park_check"
#define REMOTE_auto_recover     "auto_recover"

#define REMOTE_lifter           "lifter"
#define REMOTE_turner           "turner"
#define REMOTE_putter           "putter"
#define REMOTE_brush            "brush"

#define REMOTE_swing            "swing"
#define REMOTE_dryer_blow       "dryer_blow"

//define perr println
#define perr_remote(format,args...) perr("server: "format,##args)
#define println_remote(format,args...) println("server: "format,##args)


/*********************data type define********************/
// device type
typedef enum{
    device_null=0,
    device_station,
    device_washer,
    device_dryer,
    device_lite,
    device_swift,
    device_custom,
    DEVICE_AV,
    DEVICE_AG,
    device_max
}DEVICE_type;


//station functions
typedef struct{
    int (*set_robot_num)(int);  //设定机器数量, param:robot number, return: 0=success
    void (*park_check)(int);    //设定引导检查是否启用, param: 1=check,0=not check
    void (*auto_recover)(int);
}REMOTE_station;

//robot common api
typedef struct{
    void (*unemergency)(void);  //急停恢复
    int (*auto_back)(void); //自动归位，return 0=success
    int (*recover)(void);   //一键恢复,return 0=success
    void (*max_hight)(float);   //设定最大高度, param value: m
    int (*forward)(int);    //前进, param: speed, m/s, return: 0=success
    int (*back)(int);   //后退, param: speed, m/s, return: 0=success
    int (*left)(void);   //左拐,return: 0=success
    int (*right)(void);  //右拐,return: 0=success
    int (*stop)(void);   //停止,return: 0=success
    void (*lidar_blow)(void); //雷达吹气
    int (*standby_point)(int,int,float);  //设定待机坐标,param: x,y,angle, return:0=success
    int (*goto_point)(int,int,float);  //设定移动目标坐标 ,param: x,y,angle, return:0=success
}REMOTE_robot_common;

//washer api
typedef struct{
    int (*lifter)(float);   //升降, param: hight value, m ,  return: 0=success
    int (*turner)(int); //举平, param: angle degree,  return:0=success
    int (*putter)(int); //推杆, param: route value 0~3,  return: 0=success
    int (*brush)(int);  //转刷子, param: cmd,-1=reversal,0=stop,1=forward,  return: 0=success
}REMOTE_washer;

//dryer api
typedef struct{
    int (*lifter)(float);   //升降, param: hight value, m ,  return: 0=success
    int (*swing)(int);  //风口, param: route value 0~3, return: 0=success
    int (*dryer_blow)(int);  //吹风, param: cmd ,-1=reversal,0=stop,1=forward, return:0=success
}REMOTE_dryer;

// point coordinate
typedef struct{
    int x;
    int y;
    float angle;
}REMOTE_point;

//remote cmd class
typedef struct{
    int init;   //初始化状态
    DEVICE_type type;   //remote device type
    REMOTE_station station;
    REMOTE_robot_common robot_common;
    REMOTE_washer washer;
    REMOTE_dryer dryer;
}REMOTE;


/********************function extern***********************/
// extern int remote_basic_cmd(const char *cmd,const char *param); //basic cmd deal
// extern int xp_remoteCmd_robot_common(const char *cmd,const char *param);    //robot common cmd
// extern int xp_remoteCmd_station_common(const char *cmd,const char *param);  //station common cmd
// extern int xp_remoteCmd_washer(const char *cmd,const char *param);  //washer cmd
// extern int xp_remoteCmd_dryer(const char *cmd,const char *param);   //dryer cmd
extern int xp_remoteCmd_init(DEVICE_type type); //remote init
extern int xp_remoteCmd_deal(DEVICE_type type,const char *cmd,const char *param);   //remote cmd deal



#endif
//end of the file
